﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;

namespace FloodFree.Common
{
    
    public class FloodFreeContext : DbContext
    {

        public FloodFreeContext()
            : base("FloodFreeContext")
        { }

        public DbSet<Sensor> Sensors { get; set; }
        public DbSet<City> Cities { get; set; }
        public DbSet<State> States { get; set; }
        public DbSet<Subscription> Subscriptions { get; set; }
        public DbSet<SensorUpdate> SensorUpdates { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<State>().HasMany(j => j.Cities).WithRequired().WillCascadeOnDelete();

            modelBuilder.Entity<State>().HasMany(x => x.Cities);
           
        }
    }
}
